//
//  LRJBaseTableViewCell.m
//  LRJAansyDraw_Example
//
//  Created by imac_LRJ on 2022/6/28.
//  Copyright © 2022 imac_LRJ. All rights reserved.
//

#import "LRJBaseTableViewCell.h"
#import "UIImage+Graver.h"

#import "LRJ_TextParagrapStyle.h"
#import "NSMutableAttributedString+advanceMethods.h"
//
#import "NSAttributedString+drawAndCalculate.h"
#import "LRJ_CTextLayout.h"
@implementation LRJBaseTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        _orderContentView = [[LRJ_SampleCoreTextView alloc] initWithFrame:CGRectMake(10, 5, 0, 0)];
        _orderContentView.cornerRadius = 2;
        _orderContentView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_orderContentView];
    }
    return self;
}


- (void)setData:(LRJ_MutableAttributedItem *)itme1
{

    
    __weak typeof(self) weakSelf = self;
    _orderContentView.attributedItem = itme1;
    __weak typeof(_orderContentView) weakViewBase = _orderContentView;
    _orderContentView.trancatedBlock = ^{
        itme1.nums = YES;
        itme1.height = [itme1.resultString wmg_sizeConstrainedToWidth:[UIScreen mainScreen].bounds.size.width - 20 numberOfLines:0].height;
        [weakSelf.weakTab reloadRowsAtIndexPaths:@[itme1.indexP] withRowAnimation:UITableViewRowAnimationAutomatic];
    };
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"展开"];
    [str wmg_setFont:[UIFont systemFontOfSize:22]];
    [str wmg_setColor:[UIColor orangeColor]];
    
    if (itme1.nums == YES) {
        _orderContentView.numerOfLines = 0;
    } else {
        _orderContentView.numerOfLines = 3;
        _orderContentView.textDrawer.textLayout.truncationString = str;
    }

//    CGSize size = [itme1.resultString wmg_sizeConstrainedToWidth:[UIScreen mainScreen].bounds.size.width - 20 numberOfLines:3];
    _orderContentView.frame = CGRectMake(10, 10, [UIScreen mainScreen].bounds.size.width - 20, itme1.height + 5);
    _orderContentView.backgroundColor = [UIColor blackColor];
    
    
}

//- (void)setupCellData:(DemoOrderCellData *)cellData
//{
//    _orderContentView.frame = CGRectMake(10, 5, cellData.cellWidth, cellData.cellHeight-10);
//    _orderContentView.drawerDates = cellData.textDrawerDatas;
//}


@end
